package com.diaohw.module.system.obj.tables;

import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.table.TableDef;

import java.io.Serial;

/**
 * 用户登录日志 表定义层。
 *
 * @author D-Hw
 * @since 2024-11-15 18:22:15
 */
public class LoginLogDef extends TableDef {

    @Serial
    private static final long serialVersionUID = 1L;

    /**
     * 用户登录日志
     */
    public static final LoginLogDef LOGIN_LOG = new LoginLogDef();

    /**
     * ID
     */
    public final QueryColumn ID = new QueryColumn(this, "ID");

    /**
     * 创建时间
     */
    public final QueryColumn CREATED = new QueryColumn(this, "CREATED_TIME");

    /**
     * 登录IP
     */
    public final QueryColumn LOGIN_IP = new QueryColumn(this, "LOGIN_IP");

    /**
     * 用户昵称
     */
    public final QueryColumn NICKNAME = new QueryColumn(this, "NICKNAME");

    /**
     * 用户登录账号
     */
    public final QueryColumn USERNAME = new QueryColumn(this, "USERNAME");

    /**
     * 创建人
     */
    public final QueryColumn ACCOUNT_ID = new QueryColumn(this, "ACCOUNT_ID");

    /**
     * 浏览器
     */
    public final QueryColumn LOGIN_BROWSER = new QueryColumn(this, "LOGIN_BROWSER");


    /**
     * 默认字段，不包含逻辑删除或者 large 等字段。
     */
    public final QueryColumn[] DEFAULT_COLUMNS = new QueryColumn[]{ACCOUNT_ID, CREATED, USERNAME, NICKNAME, LOGIN_IP, LOGIN_BROWSER};

    public LoginLogDef() {
        super("", "LOGIN_LOG");
    }

    private LoginLogDef(String schema, String name, String alisa) {
        super(schema, name, alisa);
    }

    public LoginLogDef as(String alias) {
        String key = getNameWithSchema() + "." + alias;
        return getCache(key, k -> new LoginLogDef("", "LOGIN_LOG", alias));
    }

    /**
     * 所有字段。
     */
    public final QueryColumn AllColumns = new QueryColumn(this, "*");

}
